
# check if CUDA is available
NVCC_RESULT := $(shell which nvcc 2> NULL)
NVCC_TEST := $(notdir $(NVCC_RESULT))

SOURCE   = src
INCLUDE  = -I./include
BUILD    = build

CFLAGS = -m64 -O3 
CUFLAGS = -arch sm_20


OBJ_GCC = $(BUILD)/TerrainGuarding.o $(BUILD)/GK_PC_solver.o  $(BUILD)/tinythread.o $(BUILD)/main.o 
OBJ_NVCC = $(OBJ_GCC) $(BUILD)/cuGK_PC_solver.o 

ifeq ($(NVCC_TEST),nvcc)
	CC:=nvcc
	CFLAGS := -arch=sm_20 -Xcompiler "-m64 -O3"
	OFLAGS := -x cu -dc
	OBJ = $(OBJ_NVCC)
	LIBS = -lpthread
else
	CC:=g++
	CFLAGS := -O3
	OFLAGS := -g3
	OBJ = $(OBJ_GCC)
	LIBS = -lpthread


endif

all: $(OBJ)
	@$(CC) $(CFLAGS) $(OBJ) -o TG_solver

$(BUILD)/%.o : $(SOURCE)/%.cpp
	@$(CC) $(CFLAGS) $(OFLAGS) $(INCLUDE) $< -o $@ 



test:
	@echo $(CC)



clean:
	@rm -f $(BUILD)/*.o main TG_solver


	
	
	
	
